//
//  CFCalendarCell.m
//  CFfuturestalent
//
//  Created by 子yu 刘 on 2018/4/26.
//  Copyright © 2018年 子yu 刘. All rights reserved.
//

#import "CFCalendarCell.h"

@implementation CFCalendarCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;        
        [self initBaseView];
    }
    return self;
}

- (void)initBaseView{
    UIView * line = [[UIView alloc] init];
    line.backgroundColor = DEF_COLOR_HEX_DCDCDC;
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.bottom.mas_equalTo(self);
        make.height.mas_offset(1);
    }];
    
    UILabel * weekLabel = [[UILabel alloc] init];
    self.lbWeek = weekLabel;
    weekLabel.textColor = DEF_COLOR_HEX_333333;
    weekLabel.textAlignment = NSTextAlignmentCenter;
    weekLabel.font = [UIFont systemFontOfSize:13.0];
    [self.contentView addSubview:weekLabel];
    [weekLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(15);
    }];
    
    UILabel * dateLabel =[[UILabel alloc] init];
    self.lbDate = dateLabel;
    dateLabel.textColor = DEF_COLOR_HEX_333333;
    dateLabel.textAlignment = NSTextAlignmentCenter;
    dateLabel.font = [UIFont systemFontOfSize:13.0];
    [self.contentView addSubview:dateLabel];
    [dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.bottom.mas_equalTo(-5);
    }];

}

-(void)setIsSelected:(BOOL)isSelected{
    self.lbDate.textColor = isSelected? [UIColor colorWithHexString:@"cd1212"]:DEF_COLOR_HEX_333333;
    self.lbWeek.textColor = isSelected? [UIColor colorWithHexString:@"cd1212"]:DEF_COLOR_HEX_333333;
}

-(void)setDate:(NSDate *)date{
    self.lbWeek.text = [DateUtil getNowWeekdayByDate:date];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"YYYY年M月d日"];
    self.lbDate.text = [dateFormatter stringFromDate:date];//几月几号
}


@end
